import store from '@/store'
import config from '@/config'
import storage from '@/utils/storage'
export async function validate () {
  // let memberPhone = userInfo.mobile || ''
  let oUserInfo = storage.get('userInfo') || {}
  if (!oUserInfo.mobile) {
    return false
  }
  // let phoneVal = moment().format('MMDDYYYY') + memberPhone.substring(7) + (new Date().getDay() || 7)
  // userInfo.cdkey !== MD5(phoneVal, 32) ||
  if (!getToken()) {
    return false
  }
  let userInfo = store.state.userInfo
  if (!userInfo.mobile) {
    store.dispatch('saveUserInfo', oUserInfo)
  }
  return true
}
export function getToken () {
  let token = storage.get(config.wxStorage.TOKEN)
  return token
}
export function setToken (token = '', expireTime = 0) {
  storage.set(config.wxStorage.TOKEN, token, expireTime)
}
